<!DOCTYPE html>
<html lang="en">
<title>添加门店</title>
<#import "/layout/layout.html" as body/>
<@body.page>


<!--<link href="${baseUrl}css/upload/upload.css" rel="stylesheet">-->

<div id='wrapper-iframe' class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5 class="pull-left">新增门店</h5>
                </div>
                <div class="ibox-content">
                    <form method="post" class="form-horizontal dropzone" action="store_save" name="addForm"
                          id="addForm"
                          enctype="multipart/form-data" style="border: 0;background: none">
                        <div class="form-group"><label class="col-sm-2">基础信息</label></div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label"><b style="color: red">*</b>门店名称</label>

                            <div class="col-sm-10"><input id="storeName" name="storeName" type="text" class="form-control"></div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label">门店类型</label>

                            <div class="col-sm-10">
                                <select class="form-control m-b" name="storeType">
                                    <option value="1">CBD店</option>
                                    <option value="2">社区店</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label">经营方式</label>

                            <div class="col-sm-10">
                                <select class="form-control m-b" id="manageType" name="manageType">
                                    <option value="1">自营</option>
                                    <option value="2">加盟</option>
                                </select>
                                <input id="manageName" name="manageName" type="text" placeholder="请输入加盟商名称" class="form-control"
                                       style="margin-bottom: 15px;">
                                <input id="manageContcat" name="manageContcat" type="text" placeholder="加盟商联系方式" class="form-control">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-lg-2 control-label">店长</label>

                            <div class="col-lg-10">
                                <select class="form-control m-b chosen-select" id="storeManager" name="storeManager" data-placeholder="请选择上课教练..." tabindex="2">
                                    <#if coachList??>
                                        <#list coachList as coach>
                                            <option value="${coach.id!}">${coach.nickName!}</option>
                                        </#list>
                                    </#if>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label">地理位置</label>

                            <div id="citys" class="col-lg-10">
                                <div class="col-sm-4" style="padding-left: 0">
                                    <select class="form-control m-b" id="province" name="province"></select>
                                </div>
                                <div class="col-sm-4" style="padding-left: 0">
                                    <select class="form-control m-b" id="city" name="city"></select>
                                </div>
                                <div class="col-sm-4" style="padding-left: 0; padding-right: 0">
                                    <select class="form-control m-b" id="area" name="area"></select>
                                </div>
                                <input type="text" placeholder="输入详细地址" class="form-control" id="address" name="address"/>
                                <span style="color: red">*必填</span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label"><b style="color: red">*</b>门店坐标</label>

                            <div class="col-sm-10">
                                <input id="longitudeAndLatitude" name="longitudeAndLatitude" placeholder="输入门店所在位置经纬度, 如: 22.549244,113.944402" type="text" class="form-control">
                                <a target="_blank" href="http://lbs.qq.com/tool/getpoint/index.html">坐标查询</a>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label">门店功能</label>

                            <div class="col-sm-10">
                                <select class="form-control m-b" id="isSelfFitness" name="isSelfFitness">
                                    <option value="1">团课及自助</option>
                                    <option value="0">仅支持团课</option>
                                    <option value="2">仅支持自助</option>
                                    <option value="3">仅支持私教</option>
                                </select>
                            </div>
                        </div>
                        <div id="cDivH" class="hr-line-dashed"></div>
                        <div id="cDiv" class="form-group"><label class="col-sm-2 control-label"><b style="color: red">*</b>自助健身人数限制</label>
                            <div class="col-sm-10"><input id="maxCount" name="maxCount" type="number" min="0" class="form-control"></div>
                        </div>

                        <div id="pDivH" class="hr-line-dashed"></div>
                        <div id="pDiv" class="form-group"><label class="col-sm-2 control-label"><b style="color: red">*</b>自助健身价格</label>
                            <div class="col-sm-10"><input id="primePrice" name="primePrice" type="text" class="form-control"></div>
                        </div>
                        <div id="pDivH2" class="hr-line-dashed"></div>
                        <div id="pDiv2" class="form-group">
                            <label class="col-sm-2 control-label" style="margin-top: 10px;"><b style="color: red">*</b>会员价格</label>
                            <div class="col-sm-10" style="margin-top: 10px;"><input id="price" name="price" type="text" class="form-control"></div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label"><b style="color: red">*</b>是否支持24小时营业</label>
                            <div class="col-sm-10" id="is_24_hours">
                                <div class="checkbox-inline i-checks"><label for="is24HoursYes"> <input type="radio" id="is24HoursYes" value="1" checked name="is24Hours"> <i></i> 是 </label></div>
                                <div class="checkbox-inline i-checks"><label for="is24HoursNO"> <input type="radio" id="is24HoursNO" value="2" name="is24Hours"> <i></i> 否 </label></div>
                            </div>
                        </div>

                        <div class="form-group" id="open_time">
                            <div class="hr-line-dashed"></div>
                            <label class="col-sm-2 control-label">营业时间</label>
                            <div class="col-sm-10">
                                <div class="col-sm-6 padding-left-0">
                                    <div class="input-group clockpicker" data-autoclose="true">
                                        <input type="text" class="form-control" name="openTime" id="openTime" value="09:30" readonly>
                                        <span class="input-group-addon"><span class="fa fa-clock-o"></span></span>
                                    </div>
                                    <span>开始时间</span>
                                </div>
                                <div class="col-sm-6 padding-right-0">
                                    <div class="input-group clockpicker" data-autoclose="true">
                                        <input type="text" class="form-control" name="closeTime" id="closeTime" value="21:30" readonly>
                                        <span class="input-group-addon"><span class="fa fa-clock-o"></span></span>
                                    </div>
                                    <span>结束时间</span>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label">固定电话</label>
                            <div class="col-sm-10"><input id="tel" name="tel" type="text" class="form-control"></div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label">门店店租</label>
                            <div class="col-sm-10"><input id="storeRent" name="storeRent" type="text" class="form-control"></div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label"><b style="color: red">*</b>爆场奖励</label>
                            <div class="col-sm-10">
                                <div class="checkbox-inline i-checks"><label for="isCourseFullFeeYes"> <input type="radio" id="isCourseFullFeeYes" value="1" checked name="isCourseFullFee"> <i></i> 是 </label></div>
                                <div class="checkbox-inline i-checks"><label for="isCourseFullFeeNo"> <input type="radio" id="isCourseFullFeeNo" value="0" name="isCourseFullFee"> <i></i> 否 </label></div>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label"><b style="color: red">*</b>白板课补贴</label>
                            <div class="col-sm-10">
                                <div class="checkbox-inline i-checks"><label for="isCourseBlankFeeYes"> <input type="radio" id="isCourseBlankFeeYes" value="1" checked name="isCourseBlankFee"> <i></i> 是 </label></div>
                                <div class="checkbox-inline i-checks"><label for="isCourseBlankFeeNo"> <input type="radio" id="isCourseBlankFeeNo" value="0" name="isCourseBlankFee"> <i></i> 否 </label></div>
                            </div>
                        </div>

                        <!--合作店使用说明-->
                        <div id="Cooperation">
                            <div class="hr-line-dashed"></div>
                            <div class="form-group"><label class="col-sm-2">合作店使用说明</label></div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group"><label class="col-sm-2 control-label">檬用户可使用</label>
                                <div class="col-sm-10">
                                    
                                    <#if userHasSerivceList??>
                                    	<#list userHasSerivceList as list>
                                    		<div class="checkbox checkbox-primary checkbox-inline">
		                                        <input class="eh-check" name="userHasService" id="userHasService${list_index+1}" type="checkbox" checked="" value="${list.dictName!}">
		                                        <label for="userHasService${list_index+1}">${list.dictName!}</label>
		                                    </div>
                                    	</#list>
                                    </#if>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group"><label class="col-sm-2 control-label">檬用户不可使用</label>
                                <div class="col-sm-10">
                                	<#if userNotSerivceList??>
                                    	<#list userNotSerivceList as list>
                                    		<div class="checkbox checkbox-primary checkbox-inline">
		                                        <input class="eh-check" name="userNotService" id="userNotService${list_index+1}" type="checkbox" checked="" value="${list.dictName!}">
		                                        <label for="userNotService${list_index+1}">${list.dictName!}</label>
		                                    </div>
                                    	</#list>
                                    </#if>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">温馨提示</label>
                                <div class="col-sm-10">
                                    <textarea id="napaStoreTips" name="napaStoreTips" class="form-control" rows="3" maxlength="150"></textarea>
                                    <span class="help-block m-b-none">非必填，对檬用户在合作店的权益进行补充说明</span>
                                </div>
                            </div>
                        </div>
                        <!--合作店使用说明  and-->

                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2">展示信息</label></div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><b style="color: red">*</b>场地介绍</label>
                            <div class="col-sm-10">
                                <textarea id="venues" name="venues" class="form-control" rows="3" maxlength="150"></textarea>
                                <span class="help-block m-b-none">对场地的设施及独特性进行描述</span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label">门店特色</label>
                            <div class="col-sm-10">
                            	<input id="storeFeatures" name="storeFeatures" type="hidden" value="">
                                <div id="magicsuggest"></div>
                                <span style="color: red;">*每次输入一个按回车键结束</span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><b style="color: red">*</b>注意事项</label>
                            <div class="col-sm-10">
                                <textarea id="notice" name="notice" class="form-control" rows="3" maxlength="600"></textarea>
                                <!--<span class="help-block m-b-none">对场地的设施及独特性进行描述</span>-->
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label"><b style="color: red">*</b>服务特色</label>

                            <div class="col-sm-10">
                                <div class="checkbox checkbox-primary checkbox-inline">
                                    <input class="eh-check" name="services" id="checkbox1" type="checkbox" checked="" value="WiFi">
                                    <label for="checkbox1">WiFi</label>
                                </div>
                                <div class="checkbox checkbox-primary checkbox-inline">
                                    <input class="eh-check" name="services" id="checkbox2" type="checkbox" checked="" value="自助健身">
                                    <label for="checkbox2">自助健身</label>
                                </div>
                                <div class="checkbox checkbox-primary checkbox-inline">
                                    <input class="eh-check" name="services" id="checkbox3" type="checkbox" checked="" value="淋浴">
                                    <label for="checkbox3">淋浴</label>
                                </div>
                                <div class="checkbox checkbox-primary checkbox-inline">
                                    <input class="eh-check" name="services" id="checkbox4" type="checkbox" checked="" value="鞋子租赁">
                                    <label for="checkbox4">鞋子租赁</label>
                                </div>
                                <div class="checkbox checkbox-primary checkbox-inline">
                                    <input class="eh-check" name="services" id="checkbox5" type="checkbox" checked="" value="服装租赁">
                                    <label for="checkbox5">服装租赁</label>
                                </div>
                                <div class="checkbox checkbox-primary checkbox-inline">
                                    <input class="eh-check" name="services" id="checkbox6" type="checkbox" checked="" value="健康食物">
                                    <label for="checkbox6">健康食物</label>
                                </div>
                                <div class="checkbox checkbox-primary checkbox-inline">
                                    <input class="eh-check" name="services" id="checkbox7" type="checkbox" checked="" value="24H营业">
                                    <label for="checkbox7">24H营业</label>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><b style="color: red">*</b>门店硬照</label>
                            <div class="col-sm-10">
                                <div id="category_pic" class="dropzone">
                                    <input type="hidden" id="categoryPic" name="categoryPic">
                                    <div class="dropzone-previews"></div>
                                </div>

                                <div class="m text-left">
                                    <small>大小不能超过1.5M</small>
                                </div>

                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                    </form>
                </div>
                <div class="ibox-footer overflow">
                    <button type="button" onclick="goBackList()" class="btn btn-default pull-left">取消添加</button>
                    <button type="button" id="saveBtn" onclick="formSubmit()" class="btn btn-success pull-right">确认添加</button>
                </div>
            </div>
        </div>
    </div>
</div>

<link href="${baseUrl}css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
<!--upload-->
<link href="${baseUrl}css/plugins/magicsuggest/magicsuggest-min.css" rel="stylesheet">
<script type="text/javascript" src="${baseUrl}js/upload/promise.min.js"></script>
<script type="text/javascript" src="${baseUrl}js/upload/aliyun-oss-sdk.min.js"></script>
<script type="text/javascript" src="${baseUrl}js/upload/webToOss.js"></script>

<script src="${baseUrl}js/jquery.limitTextarea.js"></script>
<script src="${baseUrl}js/plugins/dropzone/dropzone.js"></script>
<script src="${baseUrl}js/plugins/clockpicker/clockpicker.js"></script>
<script>

    $('#citys').citys({
        required: false,
        code: 440300,
        nodata: 'hidden'
    });


    var categoryPicList = new Array();

    //返回列表页面方法
    function goBackList() {
        window.location = 'to_store_list';
    }
    //提交保存
    function formSubmit() {
        var isCheck = true;
     	
        if ($('#storeName').val().length <= 0) {
            swal('错误!', '请先填写门店名称!', 'error');
            isCheck = false;
            return false;
        }
        if ($('#province option:selected').text().trim() == '省份' || $('#city option:selected').text().trim() == '城市'
            || ($('#province option:selected').text().trim() != '省份' && $('#city option:selected').text().trim() == '城市')) {
            swal('错误!', '请先选择地理位置!', 'error');
            isCheck = false;
            return false;
        }
        if ($('#address').val().length <= 0) {
            swal('错误!', '请先填写详细地址!', 'error');
            isCheck = false;
            return false;
        }
        if ($('#longitudeAndLatitude').val().length <= 0) {
            swal('错误!', '请先填写门店坐标!', 'error');
            isCheck = false;
            return false;
        } else {
            var longAndLaArr = $('#longitudeAndLatitude').val().split(',');
            var longReg = /^[-\+]?((1[0-7]\d{1}|0?\d{1,2})\.\d{1,6}|180\.0{1,6})$/;
            var latReg = /^-?(?:90(?:\.0{1,6})?|(?:[1-8]?\d(?:\.\d{1,6})?))$/;
            if (!longAndLaArr[0].match(latReg) || !(longAndLaArr[1]).match(longReg)) {
                swal('错误!', '门店坐标不合法!', 'error');
                isCheck = false;
                return false;
            }
        }
        if ($('#isSelfFitness').val() == 1 && $('#price').val().length <= 0) {
            swal('错误!', '请先填写自助健身价格或修改自助健身选项为不支持!', 'error');
            isCheck = false;
            return false;
        }
        if ($('#openTime').val().length <= 0 || $('#closeTime').val().length <= 0) {
            swal('错误!', '请先填写营业时间!', 'error');
            isCheck = false;
            return false;
        }
//            if($('#tel').val().length<=0 ){
//                swal('错误!', '请先填写联系电话!', 'error');
//                isCheck = false;
//                return false;
//            }
        if ($('#venues').val().length <= 0) {
            swal('错误!', '请先填写场地介绍!', 'error');
            isCheck = false;
            return false;
        }
        if ($('#notice').val().length <= 0) {
            swal('错误!', '请先填写注意事项!', 'error');
            isCheck = false;
            return false;
        }
//        debugger
        if (!($(':checkbox').is(':checked'))) {
            swal('错误!', '请先至少选择一项服务特色!', 'error');
            isCheck = false;
            return false;
        }
        $('#categoryPic').val(categoryPicList.join(','));
        if ($('#categoryPic').val().length <= 0) {
            swal('错误!', '请先上传门店硬照!', 'error');
            isCheck = false;
            return false;
        } else {
//                if($('#categoryPic').val().split(',').length %2!=0){
//                    swal('错误!', '请先上传偶数量的门店硬照!', 'error');
//                    isCheck = false;
//                    return false;
//                }
        }
		
     	// 如果是加盟店 那么用户可使用的服务和不可使用的服务不能为空
        var manageType = $('#manageType option:selected').val();
        if(manageType == 2){
        	var userNotServiceLength = $("input[name='userNotService']:checked").length;
        	var userHasServiceLength = $("input[name='userHasService']:checked").length;
        	if(userHasServiceLength == 0){
        		swal('错误!', '檬用户可使用,最少要选择一个!', 'error');
        		return false;
        	}
        	if(userNotServiceLength == 0){
        		swal('错误!', '檬用户不可使用,最少要选择一个!', 'error');
        		return false;
        	}
        }
       
        var param = serializeForm($('#addForm'));
        param.province = $('#province option:selected').text();
        param.city = $('#city option:selected').text();
        param.area = $('#area option:selected').text();

        if (!isCheck) {
            return false;
        }
        $("#saveBtn").attr('disabled', "true");
        $.ajax({
            type: 'post',
            url: 'store_save',
            data: param,
            success: function (data) {
                if (data == 'success') {
                    swal('保存成功!', '页面即将重新加载,请稍后...', 'success');
                    window.setTimeout(function () {
                        window.location = 'to_store_list'
                    }, 1000);
                } else {
                    swal('保存失败!', '', 'error');
                }
            }
        });
    }


    $(document).ready(function () {

        ms = $('#magicsuggest').magicSuggest({
//            data: dataDictList,
            data: [],
            placeholder: '请输入搜索或选择',
            required: true,
            expandOnFocus: true,
            strictSuggest: true,
            displayField: 'dictName',
            valueField: 'dictName'
        });

        $(ms).on('selectionchange', function () {
//            console.log('DATA---->>' + JSON.stringify(this.getValue()));
//            dictArr = this.getValue();
			  console.log(this.getValue());	
        	  $("#storeFeatures").val(this.getValue());	
        });

        //如果已经选择了支持24小时则无需显示营业时间
        $('#is_24_hours input').on('ifChecked', function (evt) {

            if (evt.currentTarget.value == '1') {
                $('#open_time').hide();
            } else if (evt.currentTarget.value =='2') {
                $('#open_time').show();
            }
        });

        if ($('#is24HoursYes').prop('checked')) {
            $('#open_time').hide();
        }



        //营业时间
        $('.clockpicker').clockpicker();

        //初始化服务特色勾选框
        $('.eh-check').iCheck('uncheck');

        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green'
        });

        //类别硬照
        Dropzone.autoDiscover = false;
        var myDropzone = new Dropzone('#category_pic', {
            url: 'upload_pic',
            uploadMultiple: false,
            addRemoveLinks: true,
            dictDefaultMessage: '将文件拖到此处上传',
            dictFileTooBig: '文件过大',
            dictCancelUpload: '取消上传',
            dictRemoveFile: '移除文件',
            maxFilesize: 10.5,
            acceptedFiles: '.jpg,.png',
            method: 'post',
            filesizeBase: 1024,

            init: function () {
//                    var link = $('#categoryPic').val();
//                    if (!link || link.length <= 0) {
//                        link = "";
//                    }
//                    this.emit('initimage', link);
                this.on("error", function (file, response, XMLHttpRequest) {
                    swal("图片上传异常!", "图片服务器出错,即将清除无效图片,请稍后重新上传...", "error");
                    window.setTimeout(function () {
                        $('#category_pic .dz-image-preview.dz-error').remove()
                    }, 1000);
                });
                this.on('success', function (file, response, e) {
                    if (response.error) {
                        $(file.previewTemplate).children('.dz-error-mark').css('opacity', '1')
                    } else {
                        categoryPicList.push(response.url);
                    }
                });
                this.on('sending', function (file, xhr, formData) {
                    formData.append('filesize', file.size);
                });
                this.on('removedfile', function (file) {
                    var responseJson = null;
                    if (file && file.xhr && file.xhr.responseText) {
                        responseJson = $.parseJSON(file.xhr.responseText);
                    }
                    if (responseJson) {
                        $.each(categoryPicList, function (i, data) {
                            if (categoryPicList[i].indexOf(responseJson.url) > -1) {
                                categoryPicList.splice(i, 1);
                            }
                        });
                        $.post("delete_pic", {fileName: responseJson.url}, function (result) {
                            if (result) {
                                console.log(responseJson.url + '删除成功');
                            }
                        });
                    }
                    if (file.name.length > 0) {
                        for (var i = 0; i < categoryPicList.length; i++) {
                            if (categoryPicList[i].indexOf(file.name) > -1) {
                                $.post("delete_pic", {fileName: categoryPicList[i]}, function (result) {
                                    if (result) {
                                        console.log(result + '删除成功');
                                    }
                                });
                                categoryPicList.splice(i, 1);
                                break
                            }
                        }
                        console.log("文件 " + file.name + " 被移除");
                    }
                });
            }
        });
        $('#manageType').trigger('change');


        $('#venues').limitTextarea({
            maxNumber: 150,     //最大字数
            position: 'bottom', //提示文字的位置，top：文本框上方，bottom：文本框下方
            onOk: function () {
                $('#venues').css('background-color', 'white');
            },                 //输入后，字数未超出时调用的函数
            onOver: function () {
                $('#venues').css('background-color', 'lightpink');
            }                  //输入后，字数超出时调用的函数，这里把文本区域的背景变为粉红色
        });
    });

    //加盟类型判断
    $('#manageType').change(function () {
        if ($(this).val() == 1) {
            $('#manageName').hide(400);
            $('#manageContcat').hide(400);
            $('#Cooperation').hide(400);
        } else {
            $('#manageName').show(400);
            $('#manageContcat').show(400);
            $('#Cooperation').show(400);
            $('#manageName').val('');
            $('#manageContcat').val('');
        }
    });
    //是否可自助健身
    $('#isSelfFitness').change(function () {
        if ($(this).val() == 1 || $(this).val() == 2) {
            $('#pDiv').show(400);
            $('#pDivH').show(400);
            $('#cDiv').show(400);
            $('#cDivH').show(400);
            $('#pDiv2').show(400);
            $('#pDivH2').show(400);
        } else {
            $('#pDiv').hide(400);
            $('#pDivH').hide(400);
            $('#cDiv').hide(400);
            $('#cDivH').hide(400);
            $('#pDiv2').hide(400);
            $('#pDivH2').hide(400);
        }
    });
    //序列化表单为JSON对象
    function serializeForm(form) {
        var o = {};
        $.each(form.serializeArray(), function (index) {
            if (o[this['name']]) {
                o[this['name']] = o[this['name']] + ',' + this['value'];
            } else {
                o[this['name']] = this['value'];
            }
        });
        return o;
    }
    ;
</script>
</@body.page>
</html>